package JZ45_扑克牌顺子;

import java.util.ArrayList;

public class Solution {
    public boolean IsContinuous(int [] numbers) {
        if (numbers == null){
            return false;
        }
        int numOfZero = 0;
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < numbers.length; i++){
            if (numbers[i] == 0){
                numOfZero++;
            }else {
                list.add(numbers[i]);
            }
        }

        list.sort(Integer::compareTo);
        int gap = list.get(list.size() - 1) - list.get(0) - 1;

        for (int i = 1; i < list.size(); i++){
            if (list.get(i) == list.get(i - 1)){
                return false;
            }
        }

        if (gap == list.size() - 2 + numOfZero){
            return true;
        }else return false;
    }

    public static void main(String[] args) {
        int[] number = {6,0,2,0,4};
        Solution solution = new Solution();
        System.out.println(solution.IsContinuous(number));
    }
}
